Document assignment

cover_url = 'https://elgarblog.files.wordpress.com/2013/10/books1.jpg'
if (!file.exists(cover_file <- 'cover.jpg'))
  download.file(cover_url, cover_file, mode = 'wb')
knitr::include_graphics(if (identical(knitr:::pandoc_to(), 'html')) cover_url else cover_file)

Consider the following situation:

A sloppy printer produces books with an average of 2 misprints per page. You want to know how many pages in a 50 page book will have more than k misprints. Make an n x k table that shows the probability that n or fewer pages in a 50 page book will have more than k misprints.

Show and explain your work. Include equations and calculations to teach the reader how to solve the problem. Include an image of a book.

Push your solution to a github repository and submit the url for repository on blackboard. Be sure your repo includes your document as a pdf file and as an RMD file. Include other files needed to recompile your document.

Please keep in mind that the purpose of this assignment is to produce a document. The problem was SUPPOSED to be easy.

Given that the stated mean value of 2 misprints per page, assume the distribution of \(X\), the number of misprints of per page is a Poisson distribution \(P(\lambda)\) with \(\lambda=2\). The PDF of poisson distribution is \[P(X>k)=\frac{{e^{ - \lambda } \lambda ^x }}{{x!}}\] Conditioned on \(k\), the probability \(p_k\) of or more than \(k\) misprints on a page is: \[p_k=P(X>k)=1-P(X\leqslant k)=1-ppois(k, \lambda=2)\] Then we have the table of the probability that n or fewer pages in a 50 page book will have more than k misprints.

library(knitr)
n=50
k=10
prob <-matrix(ncol = k+1, nrow=n)
for (i in 1:n){
  for (j in 0:k){
    p = ppois(j, 2, lower.tail = TRUE)
    prob[i,j+1]=dbinom(i,50, prob = (1-p))
  }
  prob
}
prob = as.data.frame(prob)
colnames(prob)=paste0("k=", c(0:10))
rownames(prob)=paste0("n=", c(1:50))
kable(prob)
k=0 k=1 k=2 k=3 k=4 k=5 k=6 k=7 k=8 k=9 k=10
n=1 0.0000000 0.0000000 0.0000001 0.0037416 0.1859251 0.3653360 0.1814396 0.0519654 0.0117350 0.0023196 0.0004152
n=2 0.0000000 0.0000000 0.0000009 0.0152806 0.2531735 0.1507534 0.0202458 0.0013978 0.0000683 0.0000026 0.0000001
n=3 0.0000000 0.0000000 0.0000071 0.0407547 0.2251399 0.0406252 0.0014753 0.0000246 0.0000003 0.0000000 0.0000000
n=4 0.0000000 0.0000000 0.0000397 0.0798240 0.1470295 0.0080397 0.0000790 0.0000003 0.0000000 0.0000000 0.0000000
n=5 0.0000000 0.0000000 0.0001743 0.1224161 0.0751807 0.0012458 0.0000033 0.0000000 0.0000000 0.0000000 0.0000000
n=6 0.0000000 0.0000000 0.0006248 0.1530444 0.0313388 0.0001574 0.0000001 0.0000000 0.0000000 0.0000000 0.0000000
n=7 0.0000000 0.0000000 0.0018765 0.1603576 0.0109484 0.0000167 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=8 0.0000000 0.0000000 0.0048192 0.1436764 0.0032707 0.0000015 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=9 0.0000000 0.0000000 0.0107459 0.1117660 0.0008483 0.0000001 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=10 0.0000000 0.0000000 0.0210515 0.0763856 0.0001933 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=11 0.0000000 0.0000001 0.0365768 0.0463016 0.0000391 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=12 0.0000000 0.0000003 0.0567996 0.0250840 0.0000071 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=13 0.0000000 0.0000013 0.0793309 0.0122224 0.0000011 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=14 0.0000000 0.0000052 0.1001780 0.0053845 0.0000002 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=15 0.0000000 0.0000181 0.1148788 0.0021541 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=16 0.0000000 0.0000579 0.1200727 0.0007855 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=17 0.0000000 0.0001695 0.1147441 0.0002619 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=18 0.0000000 0.0004546 0.1005144 0.0000800 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=19 0.0000000 0.0011203 0.0808874 0.0000225 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=20 0.0000000 0.0025404 0.0599058 0.0000058 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=21 0.0000000 0.0053095 0.0408910 0.0000014 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=22 0.0000000 0.0102395 0.0257549 0.0000003 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=23 0.0000000 0.0182373 0.0149812 0.0000001 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=24 0.0000000 0.0300166 0.0080529 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=25 0.0000000 0.0456715 0.0040017 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=26 0.0000000 0.0642483 0.0018385 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=27 0.0000000 0.0835524 0.0007809 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=28 0.0000001 0.1004104 0.0003065 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=29 0.0000006 0.1114431 0.0001111 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=30 0.0000026 0.1141303 0.0000372 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=31 0.0000105 0.1077257 0.0000115 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=32 0.0000399 0.0935778 0.0000032 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=33 0.0001391 0.0746760 0.0000008 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=34 0.0004443 0.0546262 0.0000002 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=35 0.0012977 0.0365345 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=36 0.0034547 0.0222711 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=37 0.0083516 0.0123287 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=38 0.0182542 0.0061706 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=39 0.0358854 0.0027778 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=40 0.0630502 0.0011176 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=41 0.0982516 0.0003988 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=42 0.1345146 0.0001250 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=43 0.1598923 0.0000340 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=44 0.1625211 0.0000079 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=45 0.1384475 0.0000015 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=46 0.0961466 0.0000002 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=47 0.0522797 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=48 0.0208761 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=49 0.0054440 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
n=50 0.0006956 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000